import Vue from 'vue'
import VueRouter from 'vue-router';
import routerIn from './routerIn';
Vue.use(VueRouter)
const router = new VueRouter({
  mode: 'history',
  base: process.env.VUE_APP_PUBLICPATH,
  routes: routerIn
})
// 路由拦截
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面meta */
  if (to.meta.content) {
    let head = document.getElementsByTagName('head');
    let meta = document.createElement('meta');
    meta.content = to.meta.content;
    head[0].appendChild(meta)
  }
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});
export default router